package com.sign2024.sign2024project.operlog.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sign2024.sign2024core.common.CommonResult;
import com.sign2024.sign2024core.common.annotation.Log;
import com.sign2024.sign2024core.entry.sysoperlog.SysOperLog;
import com.sign2024.sign2024project.operlog.param.SysOperLogParam;
import com.sign2024.sign2024project.operlog.service.SysOperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 操作日志记录
 *
 * @author yujie
 * @data 2024/7/18 10:33
 */
@Api(tags = "操作日志")
@RestController
@RequestMapping("/api/operlog")
public class SysOperlogController {

    @Resource
    private SysOperLogService sysOperLogService;


    @Log(title = "操作日志", businessType = "查询")
    @ApiOperation(value = "分页展示操作日志记录", notes = "分页展示操作日志记录")
    @GetMapping("/page")
    public CommonResult<SysOperLog> page(SysOperLogParam param) {
        Page<SysOperLog> list = sysOperLogService.pageSysOperLog(param);
        return CommonResult.success(list);
    }

    @Log(title = "操作日志", businessType = "删除")
    @ApiOperation(value = "批量删除操作日志", notes = "批量删除操作日志")
    @PostMapping("/deleteByIds")
    public CommonResult deleteByIds(@RequestBody Long[] ids) {
        sysOperLogService.deleteOperLogByIds(ids);
        return CommonResult.success();
    }

    @Log(title = "操作日志", businessType = "查询")
    @ApiOperation(value = "根据id查看操作日志详细信息", notes = "根据id查看操作日志详细信息")
    @PostMapping("/selectById")
    public CommonResult selectById(Long operId) {
        SysOperLog sysOperLog = sysOperLogService.selectOperLogById(operId);
        return CommonResult.success(sysOperLog);
    }

    @Log(title = "操作日志", businessType = "删除")
    @ApiOperation(value = "查询模块标题列表", notes = "查询模块标题列表")
    @PostMapping("/selectTitle")
    public CommonResult<String> selectTitle() {
        List<String> list = sysOperLogService.selectTitle();
        return CommonResult.success(list);
    }

    @Log(title = "操作日志", businessType = "删除")
    @ApiOperation(value = "查询业务类型列表", notes = "查询业务类型列表")
    @PostMapping("/selectBusinessType")
    public CommonResult<String> selectBusinessType() {
        List<String> list = sysOperLogService.selectBusinessType();
        return CommonResult.success(list);
    }
}
